package com.spirng.leetcode.day03;

import java.util.HashMap;

public class TwoSum {
    public static void main(String[] args) {
        twoSum(new int[]{3,3},6);
    }
    public static int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int temp=target- nums[i];
            if(map.containsKey(temp)){
                return new int[]{i,map.get(temp)};
            }
            map.put(nums[i],i);
        }
        return nums;
    }
}
